<template>
  <div class="box">
    <div class="title">
      <div class="title_one">
        <b>前期测绘机构选取时间:</b>
        <span>{{basicData.createTime!=''?basicData.createTime:' '}}</span>
      </div>

      <div>
        <b>前期测绘机构选取方式:</b>
        <span v-show="basicData.chooseWay=='Z_F_C_G'">政府采购</span>
        <span v-show="basicData.chooseWay=='G_K_Z_B'">公开招标</span>
        <span v-show="basicData.chooseWay=='J_K_S_J_C_Q'">建库随机抽取</span>
      </div>
    </div>

    <div class="basicInfo">
      <div class="basicInfo_title">基本信息</div>
      <div class="basicInfo_content">
        <el-row :gutter="20" class="el_row">
          <el-col :span="8">
            <div class="basic">
              <strong>单位名称：</strong>
              {{basicInfo.name}}
            </div>
          </el-col>
          <el-col :span="8">
            <div class>
              <b>单位类型：</b>
              {{basicInfo.type}}
            </div>
          </el-col>
          <el-col :span="8">
            <div class="basic">
              <strong>法定代表人：</strong>
              {{basicInfo.legalRepresentName}}
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20" class="el_row">
          <el-col :span="8">
            <div>
              <b>统一社会信用代码：</b>
              {{basicInfo.uniformSocialCreditCode}}
            </div>
          </el-col>
          <el-col :span="8">
            <div class="basic">
              <strong>资质等级：</strong>
              {{basicInfo.level}}
            </div>
          </el-col>
          <el-col :span="8">
            <div>
              <b>办公地址：</b>
              {{basicInfo.officeAddress}}
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20" class="el_row">
          <el-col :span="8">
            <div class="basic">
              <strong>联系人：</strong>
              {{basicInfo.contactName}}
            </div>
          </el-col>
          <el-col :span="8">
            <div>
              <b>联系电话：</b>
              {{basicInfo.contactMobilePhone}}
            </div>
          </el-col>
        </el-row>
      </div>
    </div>

    <!-- <div class="basicInfo">
      <div class="basicInfo_title">单位人员信息</div>
      <div class="basicInfo_content">
        <el-table :data="peopleList" style="width: 100%">
          <el-table-column prop="name" label="姓名"></el-table-column>
          <el-table-column prop="num" label="身份证号"></el-table-column>
          <el-table-column prop="position" label="项目岗位"></el-table-column>
          <el-table-column prop="certificateNumber" label="注册证书/资格证书/上岗证书编号"></el-table-column>
          <el-table-column prop="mobilePhone" label="联系方式"></el-table-column>
        </el-table>
        <div class="pageStyle">
          
          <el-pagination
            @size-change="showSize"
            @current-change="showPage"
            :current-page="needInfo.page"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="needInfo.size"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalPage">
          </el-pagination>
        </div>
      </div>
    </div>-->
    <div class="basicInfo">
      <div class="basicInfo_title">附件信息</div>
      <div class="basicInfo_content basicInfo_fujian">
        <div class="fujianBox" v-if="fujianInfo.length!=0">
          <div class="bgFujian" v-for="(item,index) in fujianInfo" :key="index">
            <div
              class="fujianTitle"
            >{{(index+1)}}.{{item.fileName.substring(0,item.fileName.indexOf('.pdf'))?item.fileName.substring(0,item.fileName.indexOf('.pdf')):item.fileName}}</div>
            <div class="fujianContent">
              <div class="fujianName">
                <i class="el-icon-document icon"></i>
                <el-tooltip class="item" effect="dark" :content="item.fileName" placement="top-start">
                    <p class="fujianNamePdf">{{item.fileName}}</p>
                  </el-tooltip>
              </div>
              <div class="isHover">
                <span @click="btn_see(item,index)">查看</span>
                <span @click="btn_download(item,index)">下载</span>
              </div>
            </div>
          </div>
          
        </div>
        <div v-else class="noData">
          暂无数据
        </div>

      </div>
    </div>

    <el-dialog :title="title" :visible.sync="dialogVisible" width="60%">
      <span v-show="loadIfram==1" class="iframeLoad">
        加载中
        <div class="el-icon-loading"></div>
      </span>
      <iframe
        id="wode"
        v-show="loadIfram==2"
        frameborder="0"
        name="showHere"
        width="100%"
        height="600"
        scrolling="auto"
        :src="$https+typeUrl"
      ></iframe>
    </el-dialog>
  </div>
</template>

<script>
import xTable from "@/views/xtable.vue";
import {
  get_early_people_info,
  get_early_mapping_details
} from "@/api/earlySelect";
import { constants } from "crypto";
export default {
  components: {
    xTable
  },
  data() {
    return {
      title: "",
      dialogVisible: false,
      needInfo: {
        page: 1,
        size: 5
      },
      //peopleList: [], //人员信息
      totalPage: 0, //总页数
      basicInfo: {}, //基本信息
      fujianInfo: [], //附件信息
      basicData: "",
      typeUrl: "",
      info: "",
      loadIfram: 1
    };
  },
  created() {
    this.getDetails();
    // this.getPeople();
  },
  methods: {
    btn_download(item, index) {
      var a = document.createElement("a");
      a.setAttribute("href", this.$https + "/pc/file/download?id=" + item.id);
      a.click();
    },
    getDetails() {
      let obj = {
        projectId: localStorage.getItem("projectId")
      };
      get_early_mapping_details(obj).then(res => {
        console.log(res, "res");
        let times = new Date(res.data.createTime);
        console.log(times, "time");
        console.log(times.getFullYear(), times.getMonth() + 1, times.getDate());
        res.data.createTime =
          times.getFullYear() +
          "年" +
          (times.getMonth() + 1) +
          "月" +
          times.getDate() +
          "日";
        this.basicData = res.data;
        this.basicInfo = res.data.appEnterpriseDto;
        this.fujianInfo = res.data.fileDtoList;
      });
    },

    // getPeople() {
    //   let obj = {
    //     projectId: localStorage.getItem("projectId"),
    //     page: this.needInfo.page,
    //     size: this.needInfo.size
    //   };
    //   get_early_people_info(obj).then(res => {
    //     console.log(res, "res");
    //     this.peopleList = res.data.rows;
    //     this.totalPage = res.data.total;
    //   });
    // },
    // showPage(val) {
    //   this.needInfo.page = val;
    //   this.getPeople();
    // },
    // showSize(val){
    //   this.needInfo.size=val
    //   this.getPeople()
    // },
    btn_see(item, index) {
      console.log(item, index);
      let that = this;
      that.title = item.fileName;
      that.typeUrl = item.filePath;
      that.dialogVisible = true;
      that.$nextTick(() => {
        var iframe = document.getElementById("wode");
        iframe.onload = function() {
          console.log("加载完成");
          that.loadIfram = 2;
        };
      });
    }
  }
};
</script>

<style lang="scss">
.form .el-input__inner {
  width: 200px;
}
</style>

<style lang="scss" scoped>
.pageStyle {
  text-align: center;
  margin: 20px;
}
.box {
  margin: 30px;
  border: 1px solid #ebebeb;
  border-radius: 5px;
  // background: #fff;
  .box_ifram {
    width: 600px;
    height: 400px;
    border: 1px solid black;
    position: fixed;
    top: 50%;
    left: 50%;
    margin-left: -25%;
    margin-top: -10%;
  }
  .title {
    padding: 10px 30px;
    height: 100px;
    display: flex;
    align-items: center;
    font-size: 14px;
    background: #fff;
    border-radius: 5px;

    span {
      color: #666666;
      b {
        color: #444444;
      }
    }
    .title_one {
      margin-right: 60px;
    }
  }

  .basicInfo {
    .basicInfo_title {
      height: 50px;
      background: #f8f8f8;
      padding: 0px 30px;
      line-height: 50px;
      color: #333;
      font-size: 18px;
      font-weight: bold;
      border-top: 1px solid #ebebeb;
      border-bottom: 1px solid #ebebeb;
    }
    .basicInfo_content {
      padding: 30px 40px;
      .el_row {
        margin-bottom: 20px;
        div {
          font-size: 13px;
          color: #606266;
          display: flex;
          b {
            color: #444444;
            // width: 120px;
            display: block;
            // text-align: right;
            // margin-right: 10px;
          }
          strong {
            color: #444444;
            // width: 90px;
            display: block;
            text-align: right;
            margin-right: 10px;
          }
        }
      }
    }
    .basicInfo_content_title {
      display: flex;
      // justify-content: space-between;
    }
    .basicInfo_fujian {
      padding: 30px 20px;
    }
  }
}

.iframeLoad {
  display: flex;
  font-size: 35px;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}
.fujian {
  display: flex;
  align-items: center;
  float: left;
  margin-right: 40px;
  width: 30%;
}
.bgFujian {
  padding-bottom: 10px;
  margin-bottom: 20px;
}
.fujianTitle {
  font-size: 16px;
  color: #333;
  font-weight: bold;
  padding: 10px 20px;
  border-radius: 5px;
}
.fujianContent {
  margin-left: 30px;
  background: #f5f8fa;
  width: 380px;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  align-items: center;
}
.fujianName {
  font-size: 14px;
  font-weight: bold;
  color: #606266;
  cursor: pointer;
  margin-right: 20px;
  display: flex;
  align-items: center;
  width: 210px;
}
.fujianName .fujianNamePdf {
  margin: 0px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.fujianName .icon {
  display: block;
  font-size: 20px;
  margin-right: 10px;
  color: #409eff;
}

.isHover {
  color: #409eff;
  font-size: 13px;
  display: none;
  margin-left: 20px;
}
.isHover span {
  padding: 0px 3px;
  margin-right: 5px;
  cursor: pointer;
}
.fujianContent:hover .isHover {
  display: block;
}
.noData {
  text-align: center;
  font-weight: bold;
  font-size: 18px;
  color: #606266;
  padding: 20px;
}
</style>
